package com.itheima;


/**
 * 标准的javaBean-封装数据
 */
public class Student implements Comparable<Student> {
    String  name;
    int age;

    public Student(String name, int age)
    {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        //按学生年龄正序排序（当前学生年龄this-被比较学生年龄o）
//        return this.getAge() - o.getAge();
        //按学生年龄倒序排序（被比较学生年龄o-当前学生年龄this）
        return o.getAge() - this.getAge();
    }
}